<template>
  <el-dropdown
    class="international"
    trigger="click"
    @command="handleSetLanguage"
  >
    <div>
      <el-tooltip content="国际化">
        <svg-icon icon="language" icon-class="language"></svg-icon>
      </el-tooltip>
    </div>
    <template #dropdown>
      <el-dropdown-menu>
        <el-dropdown-item :disabled="language === 'zh'" command="zh">
          简体
        </el-dropdown-item>
        <el-dropdown-item :disabled="language === 'zh_ft'" command="zh_ft">
          繁体
        </el-dropdown-item>
        <el-dropdown-item :disabled="language === 'en'" command="en">
          English
        </el-dropdown-item>
      </el-dropdown-menu>
    </template>
  </el-dropdown>
</template>

<script>

import i18n from "@/lang";

export default {
  i18n,
  name: "LangSelect",
  data() {
    return {
      language: "zh"
    }
  },
  mounted() {
    this.language = this.$store.getters.i18n;
    this.handleSetLanguage(this.language);
  },
  methods: {
    handleSetLanguage(lang) {
      this.language = lang;
      this.$i18n.locale = lang;
      this.$store.dispatch("app/setI18n", lang);
    }
  }
}

</script>


<style>
</style>
